package com.vecspace.dayu.code.ui.dao;

import org.springframework.stereotype.Repository;
import com.vecspace.database.dao.BaseDao;
import com.vecspace.dayu.code.ui.pojo.Form;

/** DAYU-表单,操作数据库的dao类
 * @author: wanghua
 * @reviewer:
 * @template：wanghua
 */
@Repository("dayu_formDao")
public class FormDao extends BaseDao {
	/** 根据ID查询 DAYU-表单
	 * @param id   主键值
	 * @return Form
	 * @throws Exception
	 * @author wanghua
	 */
	public Form getForm(Long id) throws Exception {
		Form form = null;
		if (id != null && id != 0) {

			form = this.queryObject(Form.class, id);
			this.evict(form);
		}
		return form;
	}

	public Form getFormByTableIdAndTerminalType(Long tableId, String terminalType) throws Exception {
		Form form = this.queryObject("from Form where tableId=?0 and platformType=?1", new Object[] {tableId, terminalType});
		return form;
	}

	/** 插入或修改 DAYU-表单 
	 * @param item	要保存的对象
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	public void saveForm(Form item) throws Exception {
		this.saveOrUpdateObject(item);
		this.evict(item);
	}

	/** 根据ID删除 DAYU-表单 
	 * @param id	主键值
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	public void deleteForm(Long id) throws Exception {
		if (id != null && id != 0) {
			this.deleteObject(Form.class, id);
		}
	}
}
